﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using OGS.Contracts;
using OGS.DataAccess;

namespace OGS.Web.Models.Admin
{
    public class CategoryListModel
    {
        public List<Category> Categories { get; set; }

        public List<Category> ParentCategories { get; set; }

        public SearchAttributes SearchAttributes { get; set; }

        public string Name { get; set; }

        public int ParentCategoryID { get; set; }

        /// <summary>
        /// Populate List
        /// </summary>
        /// <param name="SearchAttributes"></param>
        public void Populate(string Name, int ParentCategoryID, SearchAttributes SearchAttributes)
        {
            Category oCategory = new Category { ParentCategoryID = ParentCategoryID };
            oCategory.CategoryLanguages = new List<CategoryLanguage>();
            oCategory.CategoryLanguages.Add(new CategoryLanguage { Name = Name });

            this.Name = Name;
            this.ParentCategoryID = ParentCategoryID;
            this.Categories = DACategory.Instance.SearchCategory(oCategory, SearchAttributes);
            this.ParentCategories = DACategory.Instance.GetCategories(0);
            this.ParentCategories.Insert(0, new Category { ID = 0, ComputedName = "All Parent Categories" });
            this.ParentCategories.Insert(0, new Category { ID = -1, ComputedName = "All Categories" });
        }

    }
}